<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/commons/jsp/taglibs.jsp"%>
<%@taglib uri="http://www.framework.com/taglib/tree" prefix="tree"%>


   <script type="text/javascript">
	   var UEDITOR_HOME_URL ="${ctx}/ueditor/"; 
	</script>

 <script type="text/javascript" charset="utf-8" src="${ctx}/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="${ctx}/ueditor/ueditor.all.min.js"> </script>
    <!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
    <!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
    <script type="text/javascript" charset="utf-8" src="${ctx}/ueditor/lang/zh-cn/zh-cn.js"></script>

    <style type="text/css">
         .td{ width:80px;}
        .tittle{ width:75%;}
        .st{
		 display:none;
		}
    </style>

<form name="addDataForm" id="addContentDataForm" method="post" action="${ctx}/business/webcontent/save">
	<input type="hidden" name="id" value="${webcontent.id}"/>
	<input type="hidden" name="createTime" value="${webcontent.createTime}"/>
	<input type="hidden" name="createrId" value="${webcontent.createrId}"/>
	<input type="hidden" name="createrName" value="${webcontent.createrName}"/>
	<table class="infoTable">
		<tbody>
		<tr>
		   <th align="right" width="6%">标题</th>
			<td colspan="5">
			<input id="newTitle" name="title" class="easyui-validatebox tittle" size="30" value="${webcontent.title}" data-options="required:true" maxlength="50"/>
		   </td>
		</tr>
		<tr>
		  <th align="right" width="6%">类型</th>
			<td >	
			<input id="type" name="type" />
		  </td>
		   <th align="right" width="6%">公示结束时间</th>
			<td>
				<input id="endShowTime" class="easyui-datetimebox" type="text" name="endShowTime" value="${webcontent.endShowTime}">
			</td>
		</tr>
		<tr>
		   <th align="right" width="6%">排序</th>
			<td ><input name="disSort" class="easyui-validatebox td" size="30" value="${webcontent.disSort}" data-options="validType:['number']" maxlength="5"/>
		   </td>
		    <th align="right" width="6%">是否显示</th>
			<td width="10%">
			  <select name="isDisplay" class="easyui-combobox" style="width:80px;">  
			    <option value='0' ${(webcontent.isDisplay==0)?"selected='selected'":""}>是</option>   
			    <option value='1' ${(webcontent.isDisplay==1)?"selected='selected'":""}>否</option>                  
			  </select>
		   </td>
		</tr>
		<tr id="exposureInfo">
			<th width="6%">曝光人全称</th>
			<td colspan="5">
			<input style="width:220px;" class="easyui-validatebox"  name="exploreUserId"  id="exploreUserId" value="${webcontent.exploreUserId }">
			</td>
		</tr>
		<tr>
		  <th align="right" width="6%">内容</th>
			<td colspan="5">
			<script id="editor" name="contentView"  type="text/plain" style="width:100%;height:500px;">${webcontent.content}</script>
				<input type="hidden" name="content" id="contentMsg" value="" >
				
				</input>
		    </td>	
		</tr>
		</tbody>
	</table>
</form>


<script type="text/javascript">

//实例化编辑器
//建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
var ue = UE.getEditor('editor');

bindWebType();
/*	$(function(){
	
	    var sBasePath = "${ctx}/fckeditor/";   
	    var oFCKeditor = new FCKeditor('contentView') ;   
	    oFCKeditor.BasePath = sBasePath ;   
	    oFCKeditor.Height = "500";
	    oFCKeditor.ReplaceTextarea();
	    bindWebType();
	});*/
	function getEditorHTMLContents() { 
		//var oEditor = FCKeditorAPI.GetInstance("contentView"); 
		//return(oEditor.GetXHTML(true)); 
		var html = ue.getContent();
		return html;
	} 
 
	function selectParentArticle(){
		selarticlePidArticleTree($('#articlePid').val());
		$('#articlePidArticleTreeDialog').dialog('open');
	}
	function bindWebType(){
		$('#type').combobox({
             url:'${ctx}/business/webcontent/typeListFromSearch?t='+new Date().getTime(),
                valueField:'id',
                textField:'name',
                onLoadSuccess: function () { //加载完成后,设置选中第一项
                var val = $(this).combobox("getData");
               for(var i=0;i<val.length;i++){
                	  if (val[i].id == '${webcontent.type}') {
                	 	 $(this).combobox("select", val[i].id);
                	 	 break;
                	 }
                	 	
                	 $(this).combobox("select", val[0].id);
                	 
                }
                
                 },
                 onSelect:function(val){
                	var typeId=$("#type").combobox('getValue');
                	if(typeId=="53"){//选中的是曝光台，显示曝光人全称输入框
                 		$("#exposureInfo").removeClass("st");//显示
                 	}else{
                 		$("#exposureInfo").addClass("st");//隐藏
                 	}
             	 }
               });
		}
	
	function bindArticleType(){
		  $.ajax({
		   url:'${ctx}/business/webtypemanage/listAll?t='+new Date().getTime(),
		   type:'post',
		   success:function(data){
		    var opt='';
		    for(var i=0;i<data.length;i++){
		      if(data[i].id=="1") continue;
		      opt+='<option value="'+data[i].id+'">'+data[i].name+'</option>';
		    }
		     $('select[name=type]').append(opt);
		   },
		   error:function(){
		   
		   }
		  });
		}
	
	/**
	*校验投标人的用户是否存在
	*/
	function onBlurValidName(ti){
		var name=$.trim($(ti).val());
		$.ajax({
			type: "post",
			async:false,
			url: "${ctx }/validate/unique",
			data:'tableName=t_reg_user_info&field=NAME&value='+name+'&id=name',
			success: function(data){
				if(data == "success"){
					result = true;//不存在
					top.$.messager.alert('提示',"该投标人不存在，请重新输入投标人全称！");
				}else {
					result = false;//存在
				}
				
			}
		});
	}
	
	/**
	   * easyui combobox 开启搜索功能,自动装载选中的项目处理函数
	   */
	  function onComboboxHidePanel() {
	    var el = $(this);
	    el.combobox('textbox').focus();
	    // 检查录入内容是否在数据里
	    var opts = el.combobox("options");
	    var data = el.combobox("getData");
	    var value = el.combobox("getValue");
	    // 有高亮选中的项目, 则不进一步处理
	    var panel = el.combobox("panel");
	    var items = panel.find(".combobox-item-selected");
	    if (items.length > 0) {
	      var values = el.combobox("getValues");
	      el.combobox("setValues", values);
	      return;
	    }
	    var allowInput = opts.allowInput;
	    if (allowInput) {
	      var idx = data.length;
	 
	      data[idx] = [];
	      data[idx][opts.textField] = value;
	      data[idx][opts.valueField] = value;
	      el.combobox("loadData", data);
	    } else {
	      // 不允许录入任意项, 则清空
	      el.combobox("clear");
	    }
	  }
	  $("#exploreUserId").combobox({
	    required: true,
	    editable: true,
	    missingMessage: '请输入',
	    valueField: "id",
	    textField: "text",
	    method: 'post',
	    url: '${ctx }/business/webcontent/comboList',
	    mode: "local",
	    onHidePanel: onComboboxHidePanel,
	    filter: function (q, row) {
	      //定义当'mode'设置为'local'时如何过滤本地数据，函数有2个参数：
	      //q：用户输入的文本。
	      //row：列表行数据。
	      //返回true的时候允许行显示。
	      //return row[$(this).combobox('options').textField].indexOf(q) > -1;
	      return row["spell"].indexOf(q) >= 0;
	    }
	  });
</script>


